<template>
  <div class="flex flex-col h-full">
    <SearchContainer @search="getData" @reset="() => formRef.resetFields()">
      <a-form ref="formRef" class="form-style-flex" :model="formState">
        <a-form-item name="stdate" label="操作日期" class="w-80">
          <a-range-picker v-model:value="formState.dateRange" format="YYYY-MM-DD" value-format="YYYY-MM-DD" />
        </a-form-item>
        <a-form-item name="djlb" label="单据类别" class="ml-4">
          <SelectItem v-model:value="formState.djlb" class="!w-64" type="DT00027" mode="multiple" max-tag-count="responsive" placeholder="请选择" />
        </a-form-item>
        <a-form-item name="ck" label="仓库" class="ml-4">
          <SelectWarehouse v-model:value="formState.ck" multiple class="!w-64" />
        </a-form-item>
        <a-form-item name="zjm" label="" class="ml-4">
          <a-input v-model:value="formState.zjm" class="w-[300px]" placeholder="物品编号/物品名称/助记码/流水单号" />
        </a-form-item>
      </a-form>
    </SearchContainer>
    <a-card class="mt-2 flex-1">
      <BaseExport type="物资" name="流水单查询" code="000171" :search-params="formState" class="mb-2">导出</BaseExport>
      <BaseTable :loading="loading" column-code="000171" :data-source="tableData" bordered fill :pagination="pagination" :scroll="{ x: 2000 }">
        <template #bodyCell="{ column, index, record }">
          <template v-if="column.dataIndex == 'no'">
            {{ index + 1 }}
          </template>
          <template v-if="column.dataIndex === 'ypmc'">
            <MedicineInfo :value="{ mc: record.ypmc, gg: record.gg, cj: record.cj }" />
          </template>
        </template>
      </BaseTable>
    </a-card>
  </div>
</template>
<script setup>
import { ref } from 'vue'
import dayjs from 'dayjs'
import SearchContainer from '@/components/SearchContainer'
// import SelectDepartment from '@/components/SelectDepartment'
import SelectWarehouse from '@/components/SelectWarehouse'
import SelectItem from '@/components/SelectItem'

import BaseTable from '@/components/BaseTable'

const formState = ref({
  dateRange: [dayjs().format('YYYY-MM-DD'), dayjs().format('YYYY-MM-DD')],
  ck: [],
  djlb: [],
  zjm: ''
})
const formRef = ref(null)
const { loading, tableData, getData, pagination } = useTable({
  url: '/materials/psiform/getLSDList',
  immediate: true,
  params: formState.value
})
</script>
